import request from '@/utils/request'

import variable from '@/utils/variables'
const baseURL = variable.URL.baseURL

// 获取用户购物车列表
export function getCartList() {
	return request({
	    baseURL: baseURL,
	    url: '/order/cart/list',
	    method: 'GET'
	})
}

// 删除单个进货车
export function deleteCart(params) {
	return request({
	    baseURL: baseURL,
	    url: '/order/cart/delete_cart',
	    method: 'DELETE',
	    params: params
	})
}

// 删除批量进货车
export function deleteCartList(params) {
	return request({
	    baseURL: baseURL,
	    url: '/order/cart/delete_by_ids',
	    method: 'DELETE',
	    params: params
	})
}

// 修改购物车返回库存
export function updateCartNum(params) {
	return request({
	    baseURL: baseURL,
	    url: '/order/cart/update_limit_cart',
	    method: 'PUT',
	    params: params
	})
}

// 根据购物车IDS查询商品列表
export function getBalanceList(params) {
	return request({
	    baseURL: baseURL,
	    url: '/order/cart/select_product_list',
	    method: 'GET',
	    params: params
	})
}

// 根据产品规格ID查询商品列表（立即购买）
export function getSelectProduct(params) {
	return request({
	    baseURL: baseURL,
	    url: '/order/cart/select_product',
	    method: 'GET',
	    params: params
	})
}

// 获取结算金额
export function getSettleAmount(params) {
	return request({
	    baseURL: baseURL,
	    url: '/order/settle/select_amount',
	    method: 'POST',
	    data: params
	})
}

// 创建订单
export function createOrder(params) {
	return request({
	    baseURL: baseURL,
	    url: '/order/settle/insert_order',
	    method: 'POST',
	    data: params
	})
}

// 获取用户购物车总数量
export function getUserCartNum(query) {
  return request({
    baseURL: baseURL,
    url: '/order/cart/count',
    method: 'GET',
    params: query
  })
}
